package com.css.ztb.web.user;

import com.css.ztb.domain.CssConfig;
import com.css.ztb.domain.SysMenu;
import com.css.ztb.domain.SysUser;
import com.css.ztb.service.MenuService;
import com.css.ztb.service.SysConfigService;
import com.css.ztb.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @author shipeilei
 * @date 2020-7-1 12:22:38
 * @desc desc
 */
@Controller
public class IndexController {
    @Autowired
    private MenuService menuService;
    @Autowired
    private SysConfigService sysConfigService;
    @Autowired
    private CssConfig cssConfig;

    @GetMapping("/index")
    public String index(ModelMap modelMap) {
        SysUser user = ShiroUtils.getSysUser();
        // 根据用户id取出菜单
        List<SysMenu> menus = menuService.selectMenusByUser(user);
        modelMap.put("menus", menus);
        modelMap.put("user", user);
        modelMap.put("sideTheme", sysConfigService.selectConfigByKey("sys.index.sideTheme"));
        modelMap.put("skinName", sysConfigService.selectConfigByKey("sys.index.skinName"));
        modelMap.put("copyrightYear", cssConfig.getCopyrightYear());
        modelMap.put("demoEnabled", cssConfig.isDemoEnabled());
        return "index";
    }
}
